home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / C++ A'Link Files / 1990 / Sep 90 / CPlus.Dev$ 9⁄14⁄90 / 0197-inline virtuals-Sep90 next >
Encoding:
Text File  |  1991-03-06  |  1.6 KB  |  58 lines  |  [TEXT/GEOL]

  1. Item forwarded  by  PERRY.G      to PIRO
  2.  
  3. Item    2982208                         11-Sept-90        11:08PDT
  4.  
  5. From:   MM.XOBJ                         MacroMind, XObject Support,PRT
  6.  
  7. To:     CPLUS.DEV$                      C++ Interest List--Developers
  8.         CPLUS.APPLE$                    C++ Interest List--Apple Employees
  9.  
  10. Sub:    inline virtuals
  11.  
  12. Can anyone answer me this?
  13.  
  14. I discovered my code suffered from the classic problem of overriding only one
  15. of two versions of a method, something like:
  16.  
  17. class Foo {
  18.     public:
  19.         ....
  20.         int doItWithA(char c);
  21.         int doItWithA(float f);
  22. };
  23. class Bar : public Foo {
  24.     public:
  25.         ....
  26.         int doItWithA(float);
  27. };
  28.  
  29. Now I want to fix this problem, and the Lippmann book says the only way to make
  30. them all available (short of resorting to scope resolution operators) is to
  31. provide a definition for all of them.  Naturally, I would like to do this
  32. without adding any overhead:
  33.  
  34. class Bar: public Foo {
  35.     public:
  36.         ....
  37.         int doItWithA(char c) {return Foo::doItWithA(c); }
  38.         int doItWithA(float f);
  39. };
  40.  
  41. The only problem is that (I saved this part for last), all of the mentioned
  42. methods are *virtual*.  It seems to me there is a fundamental conflict between
  43. virtuals and inlines.  I tried compiling this, and it seems OK, but I am still
  44. afraid I'll die and go to hell if use inline definitions of virtual functions.
  45.  
  46. Can someone tell me how thin this ice is, and where it would break?
  47.  
  48. Haim Zamir
  49. MacroMind, Inc.
  50. AppleLink MM.XOBJ
  51.  
  52. P.S.  Also does anyone know why the Compiler doesn't produce a warning when I
  53. hide multiple versions of a function with a single override?
  54.  
  55.  
  56.  
  57.  
  58.